﻿using JST.TPLMS.Entitys;
using JST.TPLMS.Entitys.Entities;
using Microsoft.EntityFrameworkCore;

namespace JST.TPLMS.DataBase
{
    public class TPLMSDbContext : DbContext
    {
        /// <summary>
        /// 用户
        /// </summary>
        public DbSet<User> User { get; set; }
        /// <summary>
        /// 供应商
        /// </summary>
        public DbSet<Supplier> Suppliers { get; set; }
        /// <summary>
        /// 货物
        /// </summary>
        public DbSet<Cargo> Cargos { get; set; }


        public TPLMSDbContext(DbContextOptions<TPLMSDbContext> options) : base(options)
        {

        }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            //          
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            //省略
            modelBuilder.Entity<Supplier>().HasData(
                new Supplier
                {
                    Id = 1,
                    Name = "大东",
                    Province = "上海",
                    City = "上海",
                    Address = "上海浦东",
                    PhoneNumber = "310"
                }, new Supplier
                {
                    Id = 2,
                    Name = "大京批发",
                    Province = "北京",
                    City = "北京",
                    Address = "北京大兴",
                    PhoneNumber = "110"
                }, new Supplier
                {
                    Id = 3,
                    Name = "奕迅",
                    Province = "重庆",
                    City = "重庆",
                    Address = "重庆高山",
                    PhoneNumber = "410"
                }
                );
        }

    }
}
